import React, {FC, useContext} from 'react';
import "./JournalInfoMeta.less";
import classNames from "classnames";
import * as API from "@/services";
import {useIntl} from "@@/exports";
import {HxConfigContext} from "@/layouts/HxConfigContext";
import {useBackendEnum} from "kf-web-library";
import {correspVal} from "@/utils/biz";
import {FormattedMessage} from "umi";

interface JournalInfoMetaProps {
  className?: string;
  journal?: API.FrontJournal
}

const JournalInfoMeta: FC<JournalInfoMetaProps> = (props) => {
  const {journal, className} = props;
  const {isZhCN} = useContext(HxConfigContext)
  const {enumDict, enumTypeDict, getBackendEnum} = useBackendEnum();

  if (!journal)
    return null;
  return (
    <div className={classNames("journal-info-meta-container", className)}>
      <div><span><FormattedMessage id="journal.meta.Supervisor"/> :</span>{correspVal(isZhCN, journal?.journalSupervisorUnitCn, journal?.journalSupervisorUnitEn)}</div>
      <div><span><FormattedMessage id="journal.meta.Chief"/>:</span>{correspVal(isZhCN, journal?.journalEditorCn, journal?.journalEditorEn)}</div>
      <div>
        <span><FormattedMessage id="journal.meta.PublicationFrequency"/>:</span>{correspVal(isZhCN, getBackendEnum?.("JournalPublicationCycle", journal?.journalPublicationCycle)?.i18EnumDesc, journal?.journalPublicationCycle)}
      </div>
      <div><span><FormattedMessage id="journal.meta.ISSN"/>:</span>{journal?.journalIssn}</div>
      <div><span><FormattedMessage id="journal.meta.Sponsor"/>:</span>{correspVal(isZhCN, journal?.journalHostUnitCn, journal?.journalHostUnitEn)}</div>
      <div><span><FormattedMessage id="journal.meta.Email"/>:</span>{journal?.journalEmail}</div>
      <div><span><FormattedMessage id="journal.meta.Language"/>:</span>{isZhCN ? getBackendEnum?.("LanguageType", journal?.journalLanguge.toUpperCase())?.i18EnumDesc:  journal?.journalLanguge?.toUpperCase()}</div>
      <div><span><FormattedMessage id="journal.meta.CN"/>:</span>{journal?.journalCn}</div>
    </div>
  );
};

export default JournalInfoMeta;
